package com.jt.www.enums.endorse;

/**
 * 年级
 */

public enum GradeEnum {

    FIRST_GRADE("一年级", "one", 1),
    SECOND_GRADE("二年级", "two", 2),
    THIRD_GRADE("三年级", "three", 3),
    FOURTH_GRADE("四年级", "four", 4),
    FIFTH_GRADE("五年级", "five", 5),
    SIX_GRADE("六年级", "six", 6),
    SEVEN_GRADE("七年级", "seven", 7),
    EIGHT_GRADE("八年级", "eight", 8),
    NINE_GRADE("九年级", "nine", 9);

    //todo   添加八九年级
    private String msg;
    private String enCode;
    private byte code;

    GradeEnum(String msg, String enCode, int code) {
        this.msg = msg;
        this.enCode = enCode;
        this.code = (byte) code;
    }

    public static byte getCodeByenCode(String enCode) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.enCode.equals(enCode)) {
                return gradeEnum.getCode();
            }
        }
        return 0;
    }

    public static byte getCodeByMsg(String msg) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.msg.equals(msg)) {
                return gradeEnum.getCode();
            }
        }
        return 0;
    }

    public static GradeEnum getByMsg(String msg) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.msg.equals(msg)) {
                return gradeEnum;
            }
        }
        return null;
    }

    public static String getMsgByCode(byte code) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.code == code) {
                return gradeEnum.getMsg();
            }
        }
        return null;
    }

    public static String getMsgByEnCode(String enCode) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.enCode.equals(enCode)) {
                return gradeEnum.getMsg();
            }
        }
        return null;
    }

    public static String getEnCodeByCode(byte code) {
        for (GradeEnum gradeEnum : GradeEnum.values()) {
            if (gradeEnum.code == code) {
                return gradeEnum.getEnCode();
            }
        }
        return null;
    }

    public String getMsg() {
        return msg;
    }

    public String getEnCode() {
        return enCode;
    }

    public byte getCode() {
        return code;
    }
}
